#define DEBUG
#include <cstdio>
#define MAXN 100000

using namespace std;

long long max(long long a, long long b) {
  return a>b ? a : b;
}

long long solve(int *a, int l, int r) {
  if (l==r) {
    return 0;
  }
  static int temp[MAXN+1];
  int mid=(l+r)/2;
  long long ret=solve(a, l, mid)+solve(a, mid+1, r);
  for (int i=l, j=mid+1, p=l; p<=r; p++) {
    if (j>r || (i<=mid && a[i]<=a[j])) {
      temp[p] = a[i];
      i++;
    } else {
      ret += mid-i+1;
      temp[p] = a[j];
      j++;
    }
  }
  for (int i=l; i<=r; i++) {
    a[i]=temp[i];
  }
  return ret;
}

int main() {
#ifdef DEBUG
  freopen("4658.in", "r", stdin);
  freopen("4658.out", "w", stdout);
#endif

  static int a[MAXN+1];
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i=1; i<=n; i++) {
    scanf("%d", a+i);
  }

  printf("%lld", max(solve(a, 1, n)-k, 0));

  fclose(stdin);
  fclose(stdout);
  return 0;
}
